package com.mine.common.core.utils.datetime;

import java.time.LocalDateTime;

/**
 * 日期时间范围
 *
 * @author gongming
 * @date 2023/9/7 15:59
 */
public class DateTimeRange {
    public static final LocalDateTime DEFAULT_DATETIME = LocalDateTime.now();
    private DateTimeType type;
    private LocalDateTime begin, end;
    private final Boolean fitTag;

    public DateTimeRange() {
        this.type = DateTimeType.DAY;
        this.begin = DEFAULT_DATETIME;
        this.end = begin;
        this.fitTag = Boolean.FALSE;
    }

    public DateTimeRange(DateTimeType type, LocalDateTime begin, LocalDateTime end) {
        this.type = type;
        this.begin = begin;
        this.end = end;
        this.fitTag = Boolean.FALSE;
    }

    public DateTimeRange(DateTimeType type, LocalDateTime begin, LocalDateTime end, Boolean enableFit) {
        this.type = type;
        this.begin = begin;
        this.end = end;
        this.fitTag = enableFit;
        if (fitTag) {
            this.type = Dates.fitDateTimeType(type, begin, end);
        }
    }

    public DateTimeType getType() {
        return type;
    }

    public void setType(DateTimeType type) {
        this.type = type;
    }

    public LocalDateTime getBegin() {
        return begin;
    }

    public void setBegin(LocalDateTime begin) {
        this.begin = begin;
    }

    public LocalDateTime getEnd() {
        return end;
    }

    public void setEnd(LocalDateTime end) {
        this.end = end;
    }

    @Override
    public String toString() {
        return "DateTimeRange{" + "type=" + type + ", begin=" + begin + ", end=" + end + '}';
    }
}
